﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MISAPP.Classify.Service;
using MISAPP.MISInterface;
using System.Linq;
using System.Text;

public partial class View_CIB_CIB_Deposit : ViewMatrix
{
    int option = 0;
    
    protected void Page_Load(object sender, EventArgs e)
    {
        criteriaList = new string[] { "Criteria", "ym", "option" };
        Title = "存款分析表";
        limit();
        serviceName = "MISAPP.Classify.Service.Service_CIB_Deposit";
        if (!IsPostBack)
        {
            FillCriteria("GetCriteriaData", "SetData");
            FillGroupBy("GetDictionaryTable", CLB_Summary);
        }
    }

   
    protected void btn_Execute_Click(object sender, EventArgs e)
    {
        Button btn = sender as Button;
        
        if (btn.ID.IndexOf("1") > 0)
        {
            option = 1;//By存款類型
        }
        if (btn.ID.IndexOf("2") > 0)
        {
            option = 2;//By客群
        }


        if (!verify(null))
        {
            return;
        }
        //找誰按了我

        execute();
        Server.Transfer("CIB_Deposit_1.aspx");
    }

    protected void execute()
    {
        List<iSelectList> CriteriaList = GetSelectCLB();
        //string[] ym = { txtYM1.Text, txtYM2.Text };
        string[] ym = { CLB_YYYYMM1.GetSelectValue() 
                          , CLB_YYYYMM2.GetSelectValue() };
        Session["Criteria"] = CriteriaList;
        Session["ym"] = ym;
        Session["option"] = option;
    }

    private bool verify(object p_obj)
    {
        bool ok = true;
        //if (!Utility.IsDateYM(txtYM1.Text))
        //{
        //    ok = false;
        //}

        //if (p_obj == null)
        //{
        //    if (!Utility.IsDateYM(txtYM2.Text))
        //    {
        //        ok = false;
        //    }
        //}


        if (ok.Equals(false))
        {
            lblResult.Text = "請輸入YYYYMM！";
        }

        return ok;
    }
}
